package leetcode.code1884;

import leetcode.IDebug;
import leetcode.helper.H;

public class Solution implements IDebug {

	int n;

	public int twoEggDrop(int n) {
		Integer[] dp = new Integer[n + 1];
		this.n = n;
		return this.twoEggDrop(1, dp);
	}

	private int twoEggDrop(int l, Integer[] dp) {
		if (l > n) {
			return 0;
		}
		if (dp[l] != null) {
			return dp[l];
		}
		int ans = Integer.MAX_VALUE;
		for (int i = l; i <= n; i++) {
			int t1 = i - l;
			int t2 = this.twoEggDrop(i + 1, dp);
			ans = Math.min(ans, Math.max(t1, t2) + 1);
		}
		dp[l] = ans;
		return ans;
	}

	@Override
	public void debug4() {
		H.compare(3, this.twoEggDrop(6));
		H.compare(2, this.twoEggDrop(2));
		H.compare(14, this.twoEggDrop(100));

	}

	@Override
	public void debug3() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug2() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug1() {
		// TODO Auto-generated method stub

	}

	public static void main(String[] args) {
		Solution so = new Solution();
		so.debug1();
		so.debug2();
		so.debug3();
		so.debug4();

	}

}
